﻿<?php
class LuyenUser_TestController extends Zend_Controller_Action
{
	public $_product=array();
	protected $data;
	//Zend_Session::start();
	//$defaultNamespace = new Zend_Session_Namespace('Default');
	public function testAction()
	{
		$orderStatus = new Model_Orderstatus();
		var_dump($orderStatus->getOrderstatusById(1));
		echo":::::::::::::::::::::::::::::::::::::::";
	}
	
	public function testcartAction()
	{
		if($_GET['m_id']){
			$modelMessages = new Model_Messages();
			$messages = $modelMessages->setMessagesReaded($_GET['m_id']);
			$this->view->messages = $messages;
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public function testcart2Action()
	{
		Zend_Session::start();	
		$defaultNamespace = new Zend_Session_Namespace('Default');
		if(!isset($defaultNamespace->cart)){	
			$defaultNamespace->cart=1;
		}
		
		if($_GET)
		{
			$defaultNamespace->url=$_GET['url'];
			$action = $_GET['action'];
			switch ($action) {
				case 'add':
					$defaultNamespace->data[$_GET['id']] = array('id'=>$_GET['id'],'soluong'=>1,'sanpham'=>$_GET['title'],'gia'=>10000,'tongtien'=>10000);
					break;
				case 'update':
					$defaultNamespace->data[$_GET['id']]['soluong']=$_GET['soluong'];
					$defaultNamespace->data[$_GET['id']]['tongtien']=$_GET['soluong']*$defaultNamespace->data[$_GET['id']]['gia'];
					//echo "update thanh cong";
					break;
				case 'delete':
					unset($defaultNamespace->data[$_GET['id']]);
					//echo "delete thanh cong";
					//var_dump($defaultNamespace->data);
					break;
			}
		}
		//var_dump($defaultNamespace->data);
		$this->view->datas = $defaultNamespace->data;	
		$this->view->cart = count($defaultNamespace->data);
		$this->view->url=$defaultNamespace->url;
	}
	
	public function testcart1Action()
	{
		Zend_Session::start();
		$defaultNamespace = new Zend_Session_Namespace('Default');
		$request = $this->getRequest();
		if(isset($defaultNamespace->numberOfPageRequests)){	
			//$defaultNamespace->numberOfPageRequests++;
			
		}else{
			$defaultNamespace->numberOfPageRequests = 1;
		}
		if(!isset($defaultNamespace->submit)){	
			//$defaultNamespace->numberOfPageRequests++;
			$defaultNamespace->submit=1;
		}
		if($_POST['submit'])
		{
			$defaultNamespace->numberOfPageRequests++;
		}
		//var_dump($request->getParam('submit'));
		$this->view->cart=$defaultNamespace->numberOfPageRequests;

	}
	public function testphpAction()
	{
		echo		 $_SERVER['PHP_SELF'];
	}
	public function successAction()
	{
	
	}
}